<?php
/**
 * 排课管理-上课学生管理
 * @copyright (c) Seer All Rights Reserved
 */

require_once 'globals.php';

$Course_Student_Model = new Course_Student_Model();
$action = $_POST['action'];
$courseID = isset($_GET['courseID']) ? $_GET['courseID'] : '';
$courseBatch = isset($_GET['courseBatch']) ? $_GET['courseBatch'] : '';

//显示在线报名用户(用户一览表检索)
if ($action == '' ) {

	$pwd = '排课管理';

	$alreadyStudents = $Course_Student_Model->alreadyStudentSelect($courseID,$courseBatch);
	$availableStudents = $Course_Student_Model->availableStudentSelect($courseID,$courseBatch);
	$courseDetails = $Course_Student_Model->courseDetailsSelect($courseID);
	include View::getView('header');
	require_once View::getView('course/course_arrange');
	include View::getView('footer');View::output();
}
//添加学生到批次
if ($action == 'add' ) {

	$pwd = '添加学生到批次';

	$courseBatch = $_POST['course_batch'];
	$courseID = $_POST['course_id'];

	$courseBatchInsert = $Course_Student_Model->getCourseBatch($courseID,$courseBatch);

	$studentsAdd = isset($_POST['avIds']) ? $_POST['avIds'] : array();

 	$Course_Student_Model->addStudent($studentsAdd,$courseID,$courseBatchInsert);

	seerDirect("course_arrange.php?courseID={$courseID}&courseBatch={$courseBatchInsert}");
}
//删除所选学生的所在批次信息
if ($action == 'DelAl' ) {

	$pwd = '删除所选学生的所在批次信息';

	$courseBatch = $_POST['course_batch'];
	$courseID = $_POST['course_id'];

	$studentsDel = isset($_POST['alIds']) ? $_POST['alIds'] : array();

	$Course_Student_Model->delAlStudent($studentsDel,$courseID,$courseBatch);

	seerDirect("course_arrange.php?courseID={$courseID}&courseBatch={$courseBatch}");
}
//删除所选学生的报名信息
if ($action == 'DelAv' ) {

	$pwd = '删除所选学生的报名信息';

	$courseID = $_POST['course_id'];

	$studentsDel = isset($_POST['avIds']) ? $_POST['avIds'] : array();

	$Course_Student_Model->delAvStudent($studentsDel,$courseID);

	seerDirect("course_arrange.php?courseID={$courseID}&courseBatch={$courseBatch}");
}